﻿<UserControl
    x:Class="XamlInspector.Presentation.ResourceControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:presentation="using:XamlInspector.Presentation"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400" x:Name="root">
    <UserControl.Resources>

        <DataTemplate x:Key="XamlResource">
            <TextBlock Text="{Binding Resource}" FontSize="14" />
        </DataTemplate>

        <DataTemplate x:Key="XamlBrushResource">
            <Rectangle Fill="{Binding Brush}" Height="20" Stroke="DimGray" StrokeThickness="1" />
        </DataTemplate>

        <DataTemplate x:Key="XamlFontWeightResource">
            <TextBlock FontSize="14" FontWeight="{Binding FontWeight}" Text="{Binding FontWeightText}" />
        </DataTemplate>

        <DataTemplate x:Key="XamlFontFamilyResource">
            <TextBlock FontSize="14" FontFamily="{Binding Resource}" Text="{Binding Name}" />
        </DataTemplate>

        <presentation:AutoDataTemplateSelector x:Name="AutoDataTemplateSelector" />

    </UserControl.Resources>
    <Grid>
        <ListBox ItemsSource="{Binding Element.Resources, ElementName=root}" HorizontalContentAlignment="Stretch" ItemTemplateSelector="{StaticResource AutoDataTemplateSelector}">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListBoxItem">
                                <Grid Margin="2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="2*" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="0.5*" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="{Binding Key}" FontSize="14" TextTrimming="CharacterEllipsis" />
                                    <ContentPresenter Grid.Column="1" Margin="10,2" VerticalAlignment="Center" HorizontalAlignment="Stretch" />
                                    <TextBlock Grid.Column="2" Text="{Binding Scope}" FontSize="14" VerticalAlignment="Center" />
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
    </Grid>
</UserControl>
